/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.rcs.servlets.utils;

import java.io.File;

/**
 *
 * @author ruben
 */
public class OS {

  private static OS instance = null;

  protected OS() {
  }

  public String getName() {
    return System.getProperty("os.name");
  }

  public String getUserDir() {
    return System.getProperty("user.home");
  }

  public static OS get() {
    if (null == instance) {
      String osName = System.getProperty("os.name").toLowerCase();

      if (osName.equalsIgnoreCase("Mac OS X"))
        instance = new MacOSX();
      else if (osName.startsWith("windows"))
        instance = new Windows();
      else
        instance = new OS();
    }

    return instance;
  }

  public boolean isLinux() {
    return false;
  }

  public boolean isWindows() {
    return false;
  }

  public boolean isMacOX() {
    return false;
  }

  public File getDefaultVideoDir() {
    return new File(getUserDir(), "Videos");
  }

  public File getDefaultAudioDir() {
    return new File(getUserDir(), "Music");
  }

  public File getDefaultPictureDir() {
    return new File(getUserDir(), "Pictures");
  }

  public static void main(String[] args) {
    System.out.println(OS.get().getName());
  }
}

////////////////////////////

class MacOSX extends OS {

  @Override
  public File getDefaultVideoDir() {
    return new File(getUserDir(), "Movies");
  }

  @Override
  public boolean isMacOX() {
    return true;
  }
}

class Windows extends OS {

  @Override
  public boolean isWindows() {
    return true;
  }
}